Resource handles are a common mechanism used in computer programming to name and reference resources. For example, an application programming interface (API) may use handles to reference resources that are exposed by the API to one or more clients. Resource handles provide a level of indirection between clients and the resources they use, which protects the resources from improper access by the clients.
When an API is invoked and is given a handle, it must resolve the handle in order to locate the actual resource that the handle represents. Typically, a handle is in some way associated with a pointer to a resource. Handle resolution is conceptually similar to locating a book within a library by using the title of the book to look up a unique number associated with the book, and then locating the book on the shelf using the number.
In systems with limited storage and processing capabilities, efficient resource handle management and resolution is especially important. Handles and their associated resolution information must be compact in order to consume minimal system memory, and the handle resolution process must be efficient. It is typical for a resource handle to be created once, and then resolved several times through calls to an API. As such, the performance of the handle resolution process can have a significant impact on the performance of a system as a whole.
Handle resolution information is typically stored in a variable length data structure. Due to the varying nature of such data structures, handle creation, deletion, and resolution processing requires that the data structure be locked. Locking the data structure provides mutually exclusive access to the data structure, which prevents multiple processing threads from attempting to modify the same 6 data structure at the same time, which may lead to corruption of the data structure.
Because handle resolution is performed with greater frequency than handle creation and deletion, it is desirable to be able to perform handle resolution without having to lock the resolution information data structures to ensure mutually exclusive access, as locking the resolution information data structures consumes processing time and can lead to additional latencies, context switching, and multi-thread synchronization overhead.